package com.chx.three.mama.fragments;


import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.chx.three.mama.R;
import com.chx.three.mama.activities.FeelingDailyActivity;
import com.chx.three.mama.activities.FindWebViewActivity;

/**
 * 发现模块界面
 */
public class FindFragment extends Fragment implements View.OnClickListener {


    public FindFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View ret = inflater.inflate(R.layout.fragment_find, container, false);

        LinearLayout findBox = (LinearLayout) ret.findViewById(R.id.f1_item);
        findBox.setOnClickListener(this);
        LinearLayout findDaily = (LinearLayout) ret.findViewById(R.id.f2_item);
        findDaily.setOnClickListener(this);
        LinearLayout findTree = (LinearLayout) ret.findViewById(R.id.f3_item);
        findTree.setOnClickListener(this);
        LinearLayout findSecret = (LinearLayout) ret.findViewById(R.id.f4_item);
        findSecret.setOnClickListener(this);
        LinearLayout findExam = (LinearLayout) ret.findViewById(R.id.f5_item);
        findExam.setOnClickListener(this);
        LinearLayout findHospital = (LinearLayout) ret.findViewById(R.id.f6_item);
        findHospital.setOnClickListener(this);
        LinearLayout findCamera = (LinearLayout) ret.findViewById(R.id.f7_item);
        findCamera.setOnClickListener(this);
        LinearLayout findTest = (LinearLayout) ret.findViewById(R.id.f8_item);
        findTest.setOnClickListener(this);
        return ret;
    }


    @Override
    public void onClick(View v) {
        int id = v.getId();

        String url ="";
        String title = "";

        Intent intent = null;
        switch (id){
            case R.id.f1_item:
                url = "http://baby.ci123.com/qq/wap/android_box.php";
                title = "百宝箱";
                intent = new Intent(getActivity(), FindWebViewActivity.class);
                break;
            case R.id.f2_item:
                intent = new Intent(getActivity(), FeelingDailyActivity.class);
                break;
            case R.id.f3_item:
                url = "http://baby.ci123.com/yunqi/android_v4/tree2.php";
                title = "好孕树";
                intent = new Intent(getActivity(), FindWebViewActivity.class);
                break;
            case R.id.f4_item:
                url = "http://baby.ci123.com/qq/act/secret/";
                title = "秘密";
                intent = new Intent(getActivity(), FindWebViewActivity.class);
                break;
            case R.id.f5_item:
                url = "http://baby.ci123.com/qq/wap/exam/index.php";
                title = "育儿考试";
                intent = new Intent(getActivity(), FindWebViewActivity.class);
                break;
            case R.id.f6_item:
                url = "http://baby.ci123.com/qq/act/yiyuan/city.php?&type=1&pid=0";
                title = "孕产医院";
                intent = new Intent(getActivity(), FindWebViewActivity.class);
                break;
            case R.id.f7_item:
                url = "";
                break;
            case R.id.f8_item:
                url = "http://baby.ci123.com/weixin/list.php";
                title = "趣味测试";
                intent = new Intent(getActivity(), FindWebViewActivity.class);
                break;
        }

        if(intent != null){
            intent.putExtra("url",url);
            intent.putExtra("title",title);
            startActivity(intent);
        }
    }
}
